﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BrokerBase.Lib.Core
{
    public class PKItem:Item,IPKItem
    {
        public virtual int Id { get; set; }

        public override bool Equals(object obj)
        {
            if (obj == null)
                return false;

            Type t1 = GetType();

            Type t2=obj.GetType();

            if (t1.Name != t2.Name && t1.Name !=t2.BaseType.Name)
                return false;

            IPKItem item = obj as IPKItem;

            if (item.Id == Id)
                return true;
            else
                return false;
        }

        public override int GetHashCode()
        {
            string str = GetType().Name + Id + Name;

            return str.GetHashCode();
        }
    }
}
